package com.example.fragmentdemo;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

/**
 * @author wdl
 */
public class MainActivity extends AppCompatActivity implements TestFragment.FragmentToActivity {

    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = findViewById(R.id.tv_tips);

        FragmentManager fragmentManager = getSupportFragmentManager();
        TestFragment testFragment = (TestFragment) fragmentManager.findFragmentById(R.id.fragment_test);
        assert testFragment != null;
        testFragment.count = 10;
    }

    @Override
    public void showText(String info) {
        textView.setText(info);
    }
}
